package com.zx.centers.dataservice.mybatis.mapper.crawler;

import com.zx.centers.dataservice.mybatis.domain.crawler.CralwerWeather;
import org.apache.ibatis.jdbc.SQL;

public class CralwerWeatherSqlProvider {

    public String insertSelective(CralwerWeather record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("cralwer_weather");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }
        
        if (record.getWeatherDate() != null) {
            sql.VALUES("weather_date", "#{weatherDate,jdbcType=DATE}");
        }
        
        if (record.getWeatherCountry() != null) {
            sql.VALUES("weather_country", "#{weatherCountry,jdbcType=VARCHAR}");
        }
        
        if (record.getWeatherCity() != null) {
            sql.VALUES("weather_city", "#{weatherCity,jdbcType=VARCHAR}");
        }
        
        if (record.getWeatherStatus() != null) {
            sql.VALUES("weather_status", "#{weatherStatus,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(CralwerWeather record) {
        SQL sql = new SQL();
        sql.UPDATE("cralwer_weather");
        
        if (record.getWeatherDate() != null) {
            sql.SET("weather_date = #{weatherDate,jdbcType=DATE}");
        }
        
        if (record.getWeatherCountry() != null) {
            sql.SET("weather_country = #{weatherCountry,jdbcType=VARCHAR}");
        }
        
        if (record.getWeatherCity() != null) {
            sql.SET("weather_city = #{weatherCity,jdbcType=VARCHAR}");
        }
        
        if (record.getWeatherStatus() != null) {
            sql.SET("weather_status = #{weatherStatus,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}